package com.wanbangee.marksystem.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONArray;
import com.wanbangee.marksystem.entities.UGrade;
import com.wanbangee.marksystem.entities.UGradeSubjectRelation;
import com.wanbangee.marksystem.entities.USubject;
import com.wanbangee.marksystem.service.UGradeSubjectRelationService;

@RestController
@RequestMapping("gradeSubjectRelation")
public class UGradeSubjectRelationController {
	
	@Autowired
	private UGradeSubjectRelationService uGradeSubjectRelationService;
	
	@GetMapping("selectSubjectBygraId")
	public Map<String, Object> selectSubjectBygraId(int schId, int graId) {
		Map<String, Object> map = new HashMap<String, Object>();
		List<UGradeSubjectRelation> lists = this.uGradeSubjectRelationService.selectSubjectBygraId(schId, graId);
		map.put("code", "1001");
		map.put("message", "接口成功");
		map.put("lists", lists);
		return map;
	}
	@PostMapping("insertSubjectIntoGrade")
	public Map<String, Object> insertSubjectIntoGrade(@RequestBody JSONArray jsonArray) {
		return this.uGradeSubjectRelationService.insertSubjectIntoGrade(jsonArray);
	}
	
	@GetMapping("selectGradeBySchId")
	public Map<String, Object> selectGradeBySchId(int schId) {
		Map<String, Object> map = new HashMap<String, Object>();
		List<UGrade> list = this.uGradeSubjectRelationService.selectGradeBySchId(schId);
		map.put("code", 1001);
		map.put("message", "接口成功");
		map.put("list", list);
		return map;
	}

}
	
